﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SqlOperate;
using System.Data.SqlClient;

/// <summary>
/// 此类是对简历的实现类
/// </summary>
namespace nspJob
{
    public class RResume : IResume
    {

        #region I_Resume 成员

        ///**************************************************
        /// <summary>
        /// depiction：此方法是用于应聘者填写简历的
        /// </summary>
        /// <param name="<参数名称>"><参数说明></param>
        /// <returns>
        ///<对方法返回值的说明，该说明必须明确说明返回的值代表什么含义>
        /// </returns>
        ///Create Date：2009-9-4
        ///**************************************************
        public int Insert(TResume tr)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@WantPosition",tr.WantPosition),
					new SqlParameter("@Photo",tr.Photo),
					new SqlParameter("@Sex",tr.Sex),
					new SqlParameter("@HighestEducation",tr.HighestEducation),
					new SqlParameter("@GraduateSchool",tr.GraduateSchool),
					new SqlParameter("@NativePlace", tr.NativePlace),
					new SqlParameter("@WantAddress",tr.WantAddress),
					new SqlParameter("@TalentType", tr.TalentType),
					new SqlParameter("@DateofBirth",tr.DateofBirth),
					new SqlParameter("@MaritalStatus",tr.MaritalStatus),
					new SqlParameter("@ComputerRequest", tr.ComputerRequest),
					new SqlParameter("@EnglishRequest", tr.EnglishRequest),
					new SqlParameter("@JobDescription",tr.JobDescription),
					new SqlParameter("@PersResume",tr.PersResume),
					new SqlParameter("@WantSalary",tr.WantSalary),
					new SqlParameter("@Name",tr.Name),
					new SqlParameter("@Telephone",tr.Telephone),
					new SqlParameter("@Email",tr.Email),
					new SqlParameter("@QQ",tr.QQ),
					new SqlParameter("@Mobile", tr.Mobile),
					new SqlParameter("@ContactAddress",tr.ContactAddress),
                    new SqlParameter("@txtwork",tr.Txtwork)
            
            };
            return SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "SP_U_Resume_add", parameters);
        }

        ///**************************************************
        /// <summary>
        /// depiction：此方法是用于应聘者更新简历的
        /// </summary>
        /// <param name="<参数名称>"><参数说明></param>
        /// <returns>
        ///<对方法返回值的说明，该说明必须明确说明返回的值代表什么含义>
        /// </returns>
        ///Create Date：2009-9-4
        ///**************************************************
        public int Update(TResume tr)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@ID", tr.ID),
					new SqlParameter("@WantPosition",tr.WantPosition),
					new SqlParameter("@Photo",tr.Photo),
					new SqlParameter("@Sex",tr.Sex),
					new SqlParameter("@HighestEducation",tr.HighestEducation),
					new SqlParameter("@GraduateSchool",tr.GraduateSchool),
					new SqlParameter("@NativePlace", tr.NativePlace),
					new SqlParameter("@WantAddress",tr.WantAddress),
					new SqlParameter("@TalentType", tr.TalentType),
					new SqlParameter("@DateofBirth",tr.DateofBirth),
					new SqlParameter("@MaritalStatus",tr.MaritalStatus),
					new SqlParameter("@ComputerRequest", tr.ComputerRequest),
					new SqlParameter("@EnglishRequest", tr.EnglishRequest),
					new SqlParameter("@JobDescription",tr.JobDescription),
					new SqlParameter("@PersResume",tr.PersResume),
					new SqlParameter("@WantSalary",tr.WantSalary),
					new SqlParameter("@Name",tr.Name),
					new SqlParameter("@Telephone",tr.Telephone),
					new SqlParameter("@Email",tr.Email),
					new SqlParameter("@QQ",tr.QQ),
					new SqlParameter("@Mobile", tr.Mobile),
					new SqlParameter("@ContactAddress",tr.ContactAddress),
                   new SqlParameter("@txtwork",tr.Txtwork)
            
            };
            return SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "SP_U_Resume_Update", parameters);
        }

        ///**************************************************
        /// <summary>
        /// depiction：此方法是用于应聘者根据ID删除简历的
        /// </summary>
        /// <param name="<参数名称>"><参数说明></param>
        /// <returns>
        ///<对方法返回值的说明，该说明必须明确说明返回的值代表什么含义>
        /// </returns>
        ///Create Date：2009-9-4
        ///**************************************************
        public int Delete(int ID)
        {
            SqlParameter[] param = new SqlParameter[] 
            {
                new SqlParameter("@strwhere", "where id in (" + ID + ")"), 
                new SqlParameter("@strTableName", "U_Resume") 
            };
            return SqlHelper.DeleteByWhere("SP_DeleteByWhere", param);
        }

        ///**************************************************
        ///<summary>
        ///Depiction：<对此类的描述，可以引用系统设计中的描述>
        ///Create Date：2009-8-31
        ///</summary>
        ///**************************************************
        public DataTable GetDataTable(string table)
        {
            SqlParameter[] param = new SqlParameter[] 
            { 
                new SqlParameter("@strSelect", table+".*"),
                new SqlParameter("@strTableName",table)
            };
            return SqlHelper.ExecuteTable(CommandType.StoredProcedure, "SP_SelectByWhere", param);
        }
        ///**************************************************
        /// <summary>
        /// depiction：该方法用于根据条件查询符合条件的职位
        /// </summary>
        /// <param name="tb"><职位的实体对象></param>
        /// <returns>
        ///方法的返回值表示 是否更新成功，如果成功返回1 否则返回0
        /// </returns>
        ///Create Date：2009-8-31
        ///**************************************************
        public DataTable GetDataTableByWhere(String ParamID)
        {
            SqlParameter[] param = new SqlParameter[] 
            { 
                new SqlParameter("@strSelect","*"),
                new SqlParameter("@strwhere","where ID="+ParamID),
                new SqlParameter("@strtableName", "U_Resume")
            };
            return SqlHelper.ExecuteTable(CommandType.StoredProcedure, "SP_SelectByWhere", param);
        }
        //判断用户名是否存在
        public bool CheckUser(string name)
        {
            int num = 0;
            String sql = "select count(*)  from U_Applicant where LoginName='" + name + "'";
            SqlConnection conn = new SqlConnection(SqlHelper.ConnectionString);
            conn.Open();
            SqlCommand cmmd = new SqlCommand(sql, conn);
            num = Convert.ToInt32(cmmd.ExecuteScalar());
            conn.Close();
            if (num == 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        ///**************************************************
        /// <summary>
        /// depiction：根据登录名获取简历
        /// </summary>
        /// <param name="<参数名称>"><参数说明></param>
        /// <returns>
        ///<对方法返回值的说明，该说明必须明确说明返回的值代表什么含义>
        /// </returns>
        ///Create Date：2009-9-4
        ///**************************************************
        public DataTable GetDataTableByUname(String uname)
        {
            string sql = "select * from U_Resume a inner join U_Applicant b on(a.ID=b.ResumeID) where b.LoginName='"+uname+"'";
            DataSet dataset = new DataSet();
            SqlConnection conn = new SqlConnection(SqlHelper.ConnectionString);
            SqlDataAdapter adpter = new SqlDataAdapter(sql, conn);
            adpter.Fill(dataset);
            return dataset.Tables[0];
        }

        ///**************************************************
        /// <summary>
        /// depiction：根据id获取简历
        /// </summary>
        /// <param name="<参数名称>"><参数说明></param>
        /// <returns>
        ///<对方法返回值的说明，该说明必须明确说明返回的值代表什么含义>
        /// </returns>
        ///Create Date：2009-9-4
        ///**************************************************
        public DataTable GetDataJobResume(String ParamID)
        {
            SqlParameter[] param = new SqlParameter[] 
            { 
                new SqlParameter("@strSelect","*"),
                new SqlParameter("@strwhere","where ResumeID="+ParamID),
                new SqlParameter("@strtableName", "C_JobResume")
            };
            return SqlHelper.ExecuteTable(CommandType.StoredProcedure, "SP_SelectByWhere", param);
        }
        #endregion
    }
}
